package com.whzykj.common.wx;

import java.lang.reflect.Field;  
import java.util.Collection;  
import java.util.Iterator;
import java.util.Map;  
import java.util.Set;  
import java.util.SortedMap;
  
/** 
 * The Class MapToXMLString. 
 * 
 * @author zhumoran
 */  
public class Map2Xml {
	 public static String getRequestXml(SortedMap<String,Object> parameters){
	        StringBuffer sb = new StringBuffer();
	        sb.append("<xml>");
	        Set es = parameters.entrySet();
	        Iterator it = es.iterator();
	        while(it.hasNext()) {
	            Map.Entry entry = (Map.Entry)it.next();
	            String k = (String)entry.getKey();
	            String v = (String)entry.getValue();
	            if("sign".equalsIgnoreCase(k)){

	            }
	            else if ("attach".equalsIgnoreCase(k)||"body".equalsIgnoreCase(k)) {
	                sb.append("<"+k+">"+"<![CDATA["+v+"]]></"+k+">");
	            }
	            else {
	                sb.append("<"+k+">"+v+"</"+k+">");
	            }
	        }
	        sb.append("<"+"sign"+">"+"<![CDATA["+parameters.get("sign")+"]]></"+"sign"+">");
	        sb.append("</xml>");
	        return sb.toString();
	    }
	}
 
